package com.qf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/user")
public class UserController4 {

    @RequestMapping("/cross")
    @ResponseBody
    @CrossOrigin("http://localhost:81")
    public String cross(HttpServletResponse resp){

        //设置响应头，告诉浏览器，任何源来访问我都可以，哪怕资源不在同一个服务器也可以
//        resp.setHeader("Access-Control-Allow-Origin","http://localhost:81");
//        resp.setHeader("Access-Control-Allow-Origin","*");

        return "success~~";
    }
    @RequestMapping("/cross2")
    @ResponseBody
//    @CrossOrigin(value = "http://localhost:81")
    public String cross2(HttpServletResponse resp){

        //设置响应头，告诉浏览器，任何源来访问我都可以，哪怕资源不在同一个服务器也可以
        resp.setHeader("Access-Control-Allow-Origin","http://localhost:81");
//        resp.setHeader("Access-Control-Allow-Origin","*");

        resp.setHeader("Access-Control-Allow-Credentials","true");
        return "success~~";
    }
}
